package com.ruoyi.web.controller.medicine;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.domain.HisMedicineOrderCheck;
import com.ruoyi.service.IHisMedicineOrderCheckService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 检验记录信息Controller
 * 
 * @author ruoyi
 * @date 2024-09-03
 */
@RestController
@RequestMapping("/medicine/check")
public class HisMedicineOrderCheckController extends BaseController
{
    @Autowired
    private IHisMedicineOrderCheckService hisMedicineOrderCheckService;

    /**
     * 查询检验记录信息列表
     */
    @PreAuthorize("@ss.hasPermi('medicine:check:list')")
    @GetMapping("/list")
    public TableDataInfo list(HisMedicineOrderCheck hisMedicineOrderCheck)
    {
        startPage();
        List<HisMedicineOrderCheck> list = hisMedicineOrderCheckService.selectHisMedicineOrderCheckList(hisMedicineOrderCheck);
        return getDataTable(list);
    }

    /**
     * 导出检验记录信息列表
     */
    @PreAuthorize("@ss.hasPermi('medicine:check:export')")
    @Log(title = "检验记录信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HisMedicineOrderCheck hisMedicineOrderCheck)
    {
        List<HisMedicineOrderCheck> list = hisMedicineOrderCheckService.selectHisMedicineOrderCheckList(hisMedicineOrderCheck);
        ExcelUtil<HisMedicineOrderCheck> util = new ExcelUtil<HisMedicineOrderCheck>(HisMedicineOrderCheck.class);
        util.exportExcel(response, list, "检验记录信息数据");
    }

    /**
     * 获取检验记录信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('medicine:check:query')")
    @GetMapping(value = "/{checkId}")
    public AjaxResult getInfo(@PathVariable("checkId") Long checkId)
    {
        return success(hisMedicineOrderCheckService.selectHisMedicineOrderCheckByCheckId(checkId));
    }

    /**
     * 新增检验记录信息
     */
    @PreAuthorize("@ss.hasPermi('medicine:check:add')")
    @Log(title = "检验记录信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HisMedicineOrderCheck hisMedicineOrderCheck)
    {
        hisMedicineOrderCheck.setCheckPerson(getUserId());
        return toAjax(hisMedicineOrderCheckService.insertHisMedicineOrderCheck(hisMedicineOrderCheck));
    }

    /**
     * 修改检验记录信息
     */
    @PreAuthorize("@ss.hasPermi('medicine:check:edit')")
    @Log(title = "检验记录信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HisMedicineOrderCheck hisMedicineOrderCheck)
    {
        return toAjax(hisMedicineOrderCheckService.updateHisMedicineOrderCheck(hisMedicineOrderCheck));
    }

    /**
     * 删除检验记录信息
     */
    @PreAuthorize("@ss.hasPermi('medicine:check:remove')")
    @Log(title = "检验记录信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{checkIds}")
    public AjaxResult remove(@PathVariable Long[] checkIds)
    {
        return toAjax(hisMedicineOrderCheckService.deleteHisMedicineOrderCheckByCheckIds(checkIds));
    }
}
